From 2d10a7b9c469d6a48bdd8b5721cc00d437dcfe0a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 25 Mar 2019 08:32:50 -0400 Subject: [PATCH] gtk: Stop using gdk_surface_get_device_position Use the double version directly. --- gtk/gtkdnd.c | 14 ++++++------- gtk/gtkmenu.c | 7 ++++++- gtk/gtktooltip.c | 14 +++++++++---- gtk/gtktreeview.c | 51 ----------------------------------------------- 4 files changed, 23 insertions(+), 63 deletions(-) diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 46aeba742a..b8e5389027 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -886,6 +886,7 @@ gtk_drag_begin_internal (GtkWidget *widget, GtkDragSourceInfo *info; GtkWidget *toplevel; GdkDrag *drag; + double px, py; int dx, dy; GtkDragContent *content; @@ -893,14 +894,13 @@ gtk_drag_begin_internal (GtkWidget *widget, device = gdk_device_get_associated_device (device); toplevel = gtk_widget_get_toplevel (widget); - gtk_widget_translate_coordinates (widget, toplevel, - x, y, &x, &y); + gtk_widget_translate_coordinates (widget, toplevel, x, y, &x, &y); gdk_surface_get_device_position (gtk_widget_get_surface (toplevel), - device, - &dx, &dy, - NULL); - dx -= x; - dy -= y; + device, + &px, &py, + NULL); + dx = round (px) - x; + dy = round (py) - y; content = g_object_new (GTK_TYPE_DRAG_CONTENT, NULL); content->widget = g_object_ref (widget); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index ad0209367f..c75ff03eb8 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -1823,7 +1823,12 @@ gtk_menu_popup_at_pointer (GtkMenu *menu, device = gdk_device_get_associated_device (device); if (device) - gdk_surface_get_device_position (rect_surface, device, &rect.x, &rect.y, NULL); + { + double px, py; + gdk_surface_get_device_position_double (rect_surface, device, &px, &py, NULL); + rect.x = round (px); + rect.y = round (py); + } } } else diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index ee37687b68..c072d46106 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -618,6 +618,7 @@ gtk_tooltip_position (GtkTooltip *tooltip, const int max_x_distance = 32; /* Max 48x48 icon + default padding */ const int max_anchor_rect_height = 48 + 8; + double px, py; int pointer_x, pointer_y; /* @@ -633,9 +634,11 @@ gtk_tooltip_position (GtkTooltip *tooltip, * far away from the pointer position. */ effective_toplevel = _gtk_widget_get_surface (toplevel); - gdk_surface_get_device_position (effective_toplevel, - device, - &pointer_x, &pointer_y, NULL); + gdk_surface_get_device_position_double (effective_toplevel, + device, + &px, &py, NULL); + pointer_x = round (px); + pointer_y = round (py); if (anchor_rect.height > max_anchor_rect_height) { @@ -674,6 +677,7 @@ gtk_tooltip_position (GtkTooltip *tooltip, static void gtk_tooltip_show_tooltip (GdkDisplay *display) { + double px, py; gint x, y; GdkSurface *surface; GtkWidget *tooltip_widget; @@ -693,7 +697,9 @@ gtk_tooltip_show_tooltip (GdkDisplay *display) device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); - gdk_surface_get_device_position (surface, device, &x, &y, NULL); + gdk_surface_get_device_position_double (surface, device, &px, &py, NULL); + x = round (px); + y = round (py); gdk_surface_get_root_coords (surface, x, y, &tx, &ty); tooltip_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 3e38cb86ec..4bf4858eeb 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -6717,57 +6717,6 @@ remove_info (GtkTreeView *tree_view) g_object_set_data (G_OBJECT (tree_view), I_("gtk-tree-view-drag-info"), NULL); } -#if 0 -static gint -drag_scan_timeout (gpointer data) -{ - GtkTreeView *tree_view; - gint x, y; - GdkModifierType state; - GtkTreePath *path = NULL; - GtkTreeViewColumn *column = NULL; - GdkRectangle visible_rect; - GdkSeat *seat; - - tree_view = GTK_TREE_VIEW (data); - - seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (tree_view))); - gdk_surface_get_device_position (tree_view->priv->bin_window, - gdk_seat_get_pointer (seat), - &x, &y, &state); - - gtk_tree_view_get_visible_rect (tree_view, &visible_rect); - - /* See if we are near the edge. */ - if ((x - visible_rect.x) < SCROLL_EDGE_SIZE || - (visible_rect.x + visible_rect.width - x) < SCROLL_EDGE_SIZE || - (y - visible_rect.y) < SCROLL_EDGE_SIZE || - (visible_rect.y + visible_rect.height - y) < SCROLL_EDGE_SIZE) - { - gtk_tree_view_get_path_at_pos (tree_view, - tree_view->priv->bin_window, - x, y, - &path, - &column, - NULL, - NULL); - - if (path != NULL) - { - gtk_tree_view_scroll_to_cell (tree_view, - path, - column, - TRUE, - 0.5, 0.5); - - gtk_tree_path_free (path); - } - } - - return TRUE; -} -#endif /* 0 */ - static void add_scroll_timeout (GtkTreeView *tree_view) { -- 2.30.2